package org.example.controller;

import com.github.pagehelper.PageInfo;
import org.example.entity.PsyArticle;
import org.example.service.PsyArticleService;
import org.example.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("psyArticle")
public class PsyArticleController {
    @Autowired
    private PsyArticleService psyArticleService;

    @GetMapping("like")
    public R like(PsyArticle psyArticle,
                  @RequestParam(required = false,defaultValue = "1")int pageNum,
                  @RequestParam(required = false, defaultValue = "3")int pageSize) {
        PageInfo<PsyArticle> psyArticlePageInfo = psyArticleService.selectLikeArticle(psyArticle, pageNum, pageSize);
        return R.ok(psyArticlePageInfo);
    }

    @GetMapping("{id}")
    public R byid(@PathVariable("id") int id) {
        PsyArticle psyArticle = psyArticleService.selectPsyArticleById(id);
        return R.ok(psyArticle);

    }
}
